<?php
/**
 * Author: Zheng_Great
 * Description:  文件上传 + 富文本编辑器 测试与学习
 * Date: 2018-12-13 10:54:51
 */

namespace frontend\controllers;

use yii;
use yii\web\Controller;
use frontend\models\UploadForm; //文件上传model
use yii\web\UploadedFile;		//文件上传
use frontend\models\Cat;


class UploadController extends Controller{
	
	public function actions() {
	   	return [

			// 富文本编辑器
			// https://github.com/BigKuCha/yii2-ueditor-widget
	        'upload' => [
	            'class' => 'kucha\ueditor\UEditorAction',
	            'config' => [
	                "imageUrlPrefix"  => "",//图片访问路径前缀
	                "imagePathFormat" => "upload/image/{yyyy}{mm}{dd}/{time}{rand:6}" //上传保存路径
	                // "imageRoot" => Yii::getAlias("@webroot"),
	            ],
	        ],
			 'upload_more'=>[
                'class' => 'common\widgets\batch_upload\UploadAction'
			   ],
	    ];
	}

	// 富文本编辑器
	public function actionUed(){
		$catModel=new Cat();
		return $this->render('ueditor',['catmodel'=>$catModel]);
	}

/*******************  调用yii2 多文件上传扩展（未成功）  *********************/

	//web-upload 多文件上传
	//https://github.com/bailangzhan/yii2-webuploader
	public function actionWebUpload(){
		$request=Yii::$app->request;
		// var_dump($request->post());
		$model = new UploadForm();  // 实例化上传类
		return $this->render('webUpload',['model'=>$model]);
	}


	public function actionWebUpload2(){
		$request=Yii::$app->request;
		// var_dump($request->post());
		$model = new UploadForm();  // 实例化上传类
		return $this->render('webUpload2',['model'=>$model]);
	}

	public function actionU2(){
		// $request=Yii::$app->request;
		var_dump(Yii::$app->params['webuploader']['uploadUrl']);
		// var_dump($request->post());
	}

	//batch-upload 多文件上传阻件
	//https://github.com/zl0314/Yii2-batch-upload
	public function actionBatchUpload(){
		$request=Yii::$app->request;
		var_dump($request->post());

		$model = new UploadForm();  // 实例化上传类
		return $this->render('batchupload',['model'=>$model]);

	}


}


 ?>